package com.wing.portal.aggregation.portletinfo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.wing.cms.domain.Portlet3;
import com.wing.cms.service.ChannelManager;
import com.wing.cms.service.Portlet1Manager;
import com.wing.cms.service.Portlet3Manager;
import com.wing.common.util.SpringDI;
@Service 
public class ContentPortletInfo implements PortletInfo {

	public Map loadPortletInfo(Map<String, String> param) {
		Map root = new HashMap();
		String portletId = param.get("portletid");
		Portlet3Manager portletInstanceManager = (Portlet3Manager) SpringDI
				.getBean("portlet3Manager");
		Portlet3 portletInfo = portletInstanceManager.findById(portletId);
		if(portletInfo==null){
			root.put("portletWidth", 40);
			root.put("portletheight", 10);
			return root;
		}
		int portletWidth = portletInfo.getPortletwidth();
		int portletheight = portletInfo.getPortletheight();
		root.put("title", portletInfo.getTitle());
		root.put("contentsytle", portletInfo.getContentsytle());
		root.put("titletype", portletInfo.getTitletype()==null?"0":portletInfo.getTitletype());
		root.put("titlepic", portletInfo.getTitlepic());
		root.put("showcontent", portletInfo.getShowcontent());
		root.put("contentlength", portletInfo.getContentlength());
		root.put("contentsytle", portletInfo.getContentsytle());
		root.put("cssname", portletInfo.getCssname());
		root.put("titlecolor", portletInfo.getTitlecolor());
		root.put("portletWidth", portletWidth);
		root.put("portletheight", portletheight);
		return root;
	}
	/**
	 * 通过portletId查找模板位置
	 * 
	 * @param portletId 
	 * @return templateFilePath
	 */

	public String findTemplateFile(String portletId) {
		Portlet3Manager portletInstance3Manager = (Portlet3Manager) SpringDI
				.getBean("portlet3Manager");
		return portletInstance3Manager.findTemplateFile(portletId);
	}

}
